package com.java_foundation.huawei.Test_14;

import java.util.Scanner;

/**
 * @program: java_foundation
 * @description: 将一个英文语句以单词为单位逆序排放。例如“I am a boy”，逆序排放后为“boy a am I” 所有单词之间用一个空格隔开，
 * 语句中除了英文字母外，不再包含其他字符
 * @author: xiongbangwen <Email>xiongbangwen@163.com</Email>
 * @create: 2020-08-06 13:13
 **/
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Main m = new Main();
        while (sc.hasNext()){
            String str = sc.nextLine();
            String result = m.reverse(str);
            System.out.println(result);
        }
    }
    public String reverse(String sentence){
        String[] array = sentence.split(" ");
        StringBuffer sb = new StringBuffer();
        for (int i=array.length-1;i>=0;i--) {
            sb.append(array[i] + " ");
        }
        return sb.toString();
    }
}
